package com.pet.controller.webUser;

import com.pet.dto.web.PetHealthInformationDTO;
import com.pet.result.Result;
import com.pet.service.PetHealthInformationService;
import com.pet.vo.web.PetHealthInformationVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 员工管理
 */
@RestController
@RequestMapping("/user")
@Slf4j
public class PetHealthController {

    @Autowired
    private PetHealthInformationService petHealthInformationService;

    /**
     * 根据用户的id进行查询
     * 查询宠物健康信息
     */
    @GetMapping("/petHealthInformation")
    public Result<List<PetHealthInformationVO>> pageInvitation(){

        List<PetHealthInformationVO> voList = petHealthInformationService.selectPetHealthInformation();
        return Result.success(voList);
    }

    /**
     * 添加宠物健康信息
     */
    @PostMapping("/petHealthInformation")
    private Result insertPetHealthInformation(@RequestBody PetHealthInformationDTO dto){
        petHealthInformationService.insertPetHealthInformation(dto);
        return Result.success();
    }

    /**
     * 修改(更新)宠物健康信息
     */
    @PutMapping("/petHealthInformation")
    public Result updatePetHealthInformation(@RequestBody PetHealthInformationDTO dto){
        log.info("修改宠物健康信息:{}",dto);
        petHealthInformationService.updatePetHealthInformation(dto);
        return Result.success();
    }

    /**
     * 删除宠物健康信息
     */
    @DeleteMapping("/petHealthInformation")
    public Result deletePetHealthInformation(@RequestParam Integer id){
        log.info("删除宠物健康信息:{}",id);
        petHealthInformationService.deletePetHealthInformation(id);
        return Result.success();
    }

    /**
     * 查询指定宠物健康信息AI
     */
    @GetMapping("/petHealthInformationAI")
    public Result<String> selectPetHealthInformationAI(@RequestParam Integer id){
        log.info("查询指定宠物健康信息AI:{}",id);
        String aiAnswers = petHealthInformationService.selectPetHealthInformationAI(id);
        return Result.success(aiAnswers);
    }


}
